home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / msdos / mxmenu.zip / NIM.MNU < prev    next >
Text File  |  1991-09-28  |  6KB  |  251 lines

  1. Comment
  2. ==================================================================
  3.  
  4. The Game of NIM. CopyRight 1989-91 by Marc Perkel * All rights reserved.
  5.  
  6. In order to demonstrate the power of the MarxMenu language, I
  7. have written this game in the menu language.
  8.  
  9. This is an example of a complex menu system. It shows how the
  10. commands are used. Print this out and study it.
  11.  
  12. MarxMenu is the most powerful menu system and job control language for
  13. DOS that exists. This is but a small sample of what it can do.
  14.  
  15. The MarxMenu language is available from:
  16.  
  17. Computer Tyme
  18. 411 North Sherman, Suite 300
  19. Springfield Mo. 65802
  20. (417) 866-1222 * (800) 548-5353
  21.  
  22. This game may be distributed for free as long this file is included.
  23. Enjoy and have fun.
  24.  
  25. =========================================================
  26. EndComment
  27.  
  28. Var
  29.    ForeColor BackColor ClearChar Matches MatchRow MatchCol ChoiceRange
  30.    ChoiceCount UserChoice MyChoice MyLastChoice YourTurn X YesNo
  31.    MyResponse UserKey
  32.  
  33. Const
  34.    MatchesPerRow = 14
  35.    PauseTime = 100
  36.  
  37. if ColorScreen
  38.   ForeColor = Yellow
  39.   BackColor = Mag
  40.   ClearChar = 32
  41. else
  42.   ForeColor = Black
  43.   BackColor = Grey
  44.   ClearChar = 177
  45. endif
  46.  
  47. Explode On
  48. Shadow Off
  49. BlockBox
  50. BoxHeaderColor ForeColor BackColor
  51. BoxBorderColor Green Blue
  52. BoxInsideColor Yellow Blue
  53. InverseColor Yellow Red
  54. BlankTime 3
  55. BlankMessage 'The Game of NIM'
  56.  
  57. TextColor Red Red
  58. ClearScreen ClearChar
  59.  
  60. TextColor ForeColor BackColor
  61. ClearLine
  62. Write '  * The MarxMenu System *'
  63.  
  64. GotoXY(1,25)
  65. ClearLine
  66. WriteCenter 'Copyright 1989 by Marc Perkel * All Rights Reserved'
  67.  
  68. ClockColor ForeColor BackColor
  69. ClockPos 35 1
  70.  
  71. BoxBorderColor Yellow Mag
  72. BoxInsideColor Mag Mag
  73. DrawBox 10 4 61 17
  74. BoxBorderColor LGreen Blue
  75. BoxInsideColor Yellow Blue
  76. Shadow On
  77.  
  78. DrawBox 35 11 11 3
  79. WriteCenter 'The'
  80. Loop 5
  81.    MoveWindow -4 -1
  82.    Wait 3
  83. EndLoop
  84.  
  85. DrawBox 35 11 11 3
  86. WriteCenter 'Game'
  87. Loop 5
  88.    MoveWindow 4 -1
  89.    Wait 3
  90. EndLoop
  91.  
  92. DrawBox 35 11 11 3
  93. WriteCenter 'Of'
  94. Loop 5
  95.    MoveWindow -4 1
  96.    Wait 3
  97. EndLoop
  98.  
  99. DrawBox 35 11 11 3
  100. WriteCenter 'Nim'
  101. X = 0
  102. Loop 5
  103.    MoveWindow 4 1
  104.    Wait 3
  105. EndLoop
  106.  
  107. Wait 20
  108. DrawBox 25 11 31 3
  109. WriteCenter 'Marx Menu Demonstration'
  110. Wait 250
  111. RollWindow 4
  112. EraseTopWindow
  113. Wait 20
  114. RollWindow 3
  115. EraseTopWindow
  116. Wait 20
  117. RollWindow 2
  118. EraseTopWindow
  119. Wait 20
  120. RollWindow 1
  121. EraseTopWindow
  122. Wait 20
  123. EraseTopWindow
  124. EraseTopWindow
  125. BoxBorderColor Green Blue
  126. BoxInsideColor Yellow Blue
  127. Shadow Off
  128.  
  129. ChoiceRange = 4 + (Random mod 3)
  130.  
  131. Matches = 30 + (Random mod 9)
  132. If Matches mod (ChoiceRange + 1) = 0 Then Matches = Matches + 1
  133.  
  134. ExplodeDelay = 50
  135. Loop Matches
  136.    MatchCol = (pred(LoopIndex) mod MatchesPerRow) * 5 + 6
  137.    MatchRow = (pred(LoopIndex) / MatchesPerRow) * 6 + 3
  138.    DrawBox(MatchCol,MatchRow,3,5)
  139. EndLoop
  140. ExplodeDelay = 15
  141.  
  142. BoxBorderColor Yellow Green
  143. BoxInsideColor White Green
  144. BoxHeader '  The Game of Nim  '
  145. DrawBox 10 7 60 12
  146. TextColor LCyan Green
  147. ClearLine 205
  148. TextColor White Green
  149. Writeln
  150. Writeln ' There are ' Matches ' matches on the screen.'
  151. Writeln ' You will choose a number between 1 and ' ChoiceRange ' which
  152. Writeln ' will remove that many matches from the screen.
  153. Writeln ' Then I will remove between 1 and ' ChoiceRange ' matches.'
  154. Writeln
  155. Writeln ' Who ever takes the last match wins.'
  156. Writeln
  157. Write   ' Do you wish to play? '
  158. YesNo = ReadKey
  159. If UpperCase(YesNo) = 'Y'
  160.    Write 'Yes '
  161.    Wait PauseTime
  162.    EraseTopWindow
  163.    Repeat
  164.       YourTurn = 1
  165.       ExplodeDelay = 15
  166.       BoxBorderColor LCyan Green
  167.       BoxInsideColor Yellow Green
  168.       DrawBox 20 21 30 3
  169.       Write ' There are ' Matches ' matches left.
  170.       BoxHeader ' Your Turn '
  171.       DrawBox 64 (21 - ChoiceRange) 15 (ChoiceRange + 3)
  172.       ChoiceCount = 1
  173.       TextColor LCyan Green
  174.       ClearLine 205
  175.       TextColor Yellow Green
  176.       Writeln
  177.       Repeat
  178.          WriteCenter ChoiceCount
  179.          If ChoiceCount < ChoiceRange Then Writeln
  180.          ChoiceCount = succ(ChoiceCount)
  181.       Until ChoiceCount > ChoiceRange
  182.       UseArrows
  183.       Repeat
  184.          UserKey = ReadKey
  185.          If UserKey = Char(27)
  186.             ExitMenu
  187.          Else
  188.             UserChoice = Value(UserKey)
  189.          Endif
  190.       Until (UserChoice > 0) and (UserChoice <= ChoiceRange)
  191.       EraseTopWindow
  192.       EraseTopWindow
  193.       X = 0
  194.       While X < UserChoice
  195.          EraseTopWindow
  196.          X = X + 1
  197.          Wait 20
  198.       EndWhile
  199.       Matches = Matches - UserChoice
  200.       Wait PauseTime
  201.       If Matches > 0
  202.          YourTurn = 0
  203.          ExplodeDelay = 15
  204.          BoxBorderColor Yellow Green
  205.          BoxInsideColor White Green
  206.          DrawBox 10 21 30 3
  207.          Write ' There are ' Matches ' matches left.
  208.          DrawBox 45 21 26 3
  209.          MyChoice = Matches mod (ChoiceRange + 1)
  210.          If MyChoice = 0
  211.             If Matches = (ChoiceRange + 1)
  212.                MyChoice = 1
  213.             Else
  214.                MyChoice = Random mod Pred(ChoiceRange) + 1
  215.             Endif
  216.          Endif
  217.          MyResponse = 'I will take ' + Str(MyChoice) + ' match'
  218.          If MyChoice <> 1 Then MyResponse = MyResponse + 'es'
  219.          MyResponse = MyResponse + '.'
  220.          WriteCenter MyResponse
  221.          Wait PauseTime * 2
  222.          EraseTopWindow
  223.          EraseTopWindow
  224.          X = 0
  225.          While X < MyChoice
  226.             EraseTopWindow
  227.             X = X + 1
  228.             Wait 20
  229.          EndWhile
  230.          Matches = Matches - MyChoice
  231.          Wait PauseTime
  232.       Endif
  233.    Until Matches = 0
  234.    BoxBorderColor Yellow Mag
  235.    BoxInsideColor Mag Mag
  236.    DrawBox 20 9 44 7
  237.    BoxBorderColor LGreen Blue
  238.    BoxInsideColor Yellow Blue
  239.    DrawBox 25 11 34 3
  240.    If YourTurn = 1
  241.       WriteCenter 'Congratulations! You have WON!'
  242.    Else
  243.       WriteCenter 'Too bad! You lost!'
  244.    Endif
  245.    Wait 300
  246. Else
  247.    Write 'No'
  248.    Wait PauseTime
  249. EndIf
  250.  
  251.